package com.moonshine.parser.models;

public class VariableSignature extends AS3Signature {

	public String declaredType;
	public String declaredValue;

	public VariableSignature(int flags, int access) {
		this.flags = flags;
		this.access = access;
	}

	public String toString(Boolean pretty, Boolean omitIndices) {
		final StringBuilder sb = new StringBuilder();

		if (!AS3Signature.checkFlag(flags, Flags.TYPE_PARAMETER)) {
			sb.append((pretty ? "" : AS3Signature.checkFlag(flags,
					Flags.TYPE_CONST) ? "c " : "p ")
					+ super.toString(pretty,omitIndices) + " ");
		}
		sb.append(name);
		sb.append(":");
		if (declaredType != null)
			sb.append(declaredType);
		if (declaredValue != null)
			sb.append("=" + declaredValue);

		if (flags != Flags.TYPE_PARAMETER && !omitIndices) {
			sb.append(" ");
			AS3Signature.appendIndices(sb, this, pretty);

		}
		return sb.toString();
	}

	public VariableSignature() {
		this(Flags.TYPE_VARIABLE, Flags.ACCESS_DEFAULT);
	}

}
